import React,{useRef} from "react";
import Son from "./Son";

export default function UseMemoDemo() {

  const refInput = useRef(null);
  const sonRef = useRef(null);

  function getInput(){
    refInput.current.value = "heihei"
  }

  function getSon(){
    console.log("sonRef.current.msg",sonRef.current.msg);
    sonRef.current.fn();
  }


  return (
    <div>
      <h1>UseRef</h1>
      <input ref={refInput} type="text"  />
      <input type="button" value="获取文本框" onClick={getInput} />
      <hr />
      <Son ref={sonRef} ></Son>
      <input type="button" value="使用自定义标签" onClick={getSon} />
    </div>
  );
}
